import styles from './index.module.scss';
//定义接收参数类型
type listType = {
  type: string;
  Update: (key: string, value: string) => void;
  hideList: () => void;
};
//定义数据,方便渲染,减少注册点击事件的次数,也方便获取DOM元素
const genderList = [
  { title: '男', value: '0' },
  { title: '女', value: '1' },
];

const photoList = [
  { title: '拍照', value: '' },
  { title: '本地选择', value: '' },
];
const EditList = ({ type, Update, hideList }: listType) => {
  const list = type === 'gender' ? genderList : photoList;
  return (
    <div className={styles.root}>
      {list.map((item) => (
        <div
          key={item.title}
          className="list-item"
          onClick={() => Update(type, item.value)}
        >
          {item.title}
        </div>
      ))}
      <div className="list-item" onClick={hideList}>
        取消
      </div>
    </div>
  );
};

export default EditList;
